package com.algorithm.Heap;

import java.util.Comparator;

public abstract class AbstractHeap<E> implements Heap<E>{
    protected Comparator comparator;
    int size;

    public AbstractHeap() {
        this(null);
    }

    public AbstractHeap(Comparator comparator) {
        this.comparator = comparator;
    }

    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size == 0;
    }


    protected void emptyCheck() {
        if (size == 0) {
            throw new IndexOutOfBoundsException("heap is empty");
        }
    }

    protected void elementNotNullCheck(E element) {
        if (element == null) {
            throw new IllegalArgumentException("element must be not null");
        }
    }


}
